local ceju = fk.CreateSkill{
  name = "wk_heg__ceju",
}

Fk:loadTranslationTable{
  ["wk_heg__ceju"] = "策局",
  [":wk_heg__ceju"] = "①出牌阶段开始时，你可以令与你势力相同的角色各明置一张手牌；②与你势力相同且有明置牌的角色手牌上限+1。",
  ["#wk_heg__ceju_showCards"] = "策局：请明置一张手牌。",
}

local HG = require "packages/new_heg_diy_my/util"
local H = require "packages/ol_hegemony/util"


ceju:addEffect(fk.EventPhaseStart, {
  anim_type = "support",
  can_trigger = function (self, event, target, player, data)
     return target == player and player:hasSkill(self) and player.phase == Player.Play
  end,
  on_use = function (self, event, target, player, data)
    local room = player.room
    local targets = table.filter(room.alive_players, function (p) return H.compareKingdomWith(p, player) end)
    for _, p in ipairs(targets) do
      if p.dead then return end
      if not p:isKongcheng() then
        local card = room:askToCards(p, { 
        min_num = 1,
        max_num = 1,
        cancelable = false,
        skill_name = ceju.name,
        no_indicate = false,
        pattern = ".",
        prompt = "#wk_heg__ceju_showCards"})
        HG.showCards(p, card)
      end
    end
  end
})

ceju:addEffect("maxcards", {
  global = true,
  correct_func = function (self, player)
    local li = table.find(Fk:currentRoom().alive_players, function (p)
      return p:hasSkill(ceju.name)
    end)
    if li == nil then return end
    if H.compareKingdomWith(li, player) and #HG.getShownCards(player)>0 then
      return 1
    end
  end
})

return ceju